<?php
/**
 * Created by JetBrains PhpStorm.
 * User: khathirdstep1025
 * Date: 9/26/12
 * Time: 10:24 PM
 * To change this template use File | Settings | File Templates.
 */

class News extends CI_Controller{

    public function __construct(){
        parent::__construct();
        $this->load->model('news_model');
    }

    public function index(){
        $data['news'] = $this->news_model->get_news();
        $data['title'] = 'News archive';

        $this->parser->parse('template/header', $data);
        $this->parser->parse('news/index', $data);
        $this->parser->parse('template/footer', $data);
    }

    public function view($slug){
        $data['news_item'] = $this->news_model->get_news($slug);

        if (empty($data['news_item'])){
            show_404();
        }

        $data['title'] = $data['news_item']['title'];
        $data['text'] = $data['news_item']['text'];

        $this->parser->parse('template/header', $data);
        $this->parser->parse('news/view', $data);
        $this->parser->parse('template/footer', $data);
    }
}